<template>
	<gui-page ref="guiPage" :customHeader="true">
		<template v-slot:gHeader>
			<nav-bar-custom left-icon="left" :title="$t('distributedEnter.scanRecord')"></nav-bar-custom>
		</template>
		<template v-slot:gBody>
			<view v-if="data.barcodeList.length == 0" class="noticeHooks">
				{{ data.barcodeList.length == 0 ? $t('stockManage.notAvailable') : $t('stockManage.without') }}
			</view>
			<view class="record-card" v-for="(x, i) in data.barcodeList" :key="i" v-else>
				<uni-icons class="close-icons" type="closeempty" color="#9C9C9C" size="30"
					@click="deleteItem(i, x)"></uni-icons>
				<view class="card-mini-head">
					<view class="title-line"></view>
					<text>{{ $t('translationImage.serialNumber') }}：{{ data.barcodeList.length - i }}</text>
				</view>
				<!-- 物料代码和物料名称放一行,单位数量一行,仓库库位一行 -->
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedOut.barcode') }}：</text>{{ x.barcode }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.materialCode') }}：</text>{{ x.materialCode }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.materialName') }}：</text>{{ x.materialName }}
				</view>
				<view class="custom-card-itemOne">
					<text class="item-info-title">{{ $t('distributedEnter.materialSpec') }}：</text>{{ x.materialSpec }}
				</view>
				<view class="custom-card-itemOne">
					<view class="card-item-50">
						<text class="item-info-title">{{ $t('distributedEnter.uom') }}：</text>{{ x.unit }}
					</view>
					<view class="card-item-50">
						<text class="item-info-title">{{ $t('distributedEnter.qty') }}：</text>{{ x.currentQty }}
					</view>
				</view>
				<view class="custom-card-itemOne">
					<!-- <view class="card-item-50">
						<text class="item-info-title">{{$t('distributedEnter.uom')}}：</text>{{x.unit}}
					</view> -->
					<view class="card-item-50">
						<text class="item-info-title">{{ $t('JsInternational.onWay') }}：</text>{{ x.pathLossNum }}
					</view>
				</view>
				<view class="custom-card-itemOne">
					<view class="card-item-50">
						<text class="item-info-title">{{ $t('distributedOut.warehouse') }}：</text>{{ x.warehouseCode }}
					</view>
					<view class="card-item-50">
						<text class="item-info-title">{{ $t('distributedOut.location') }}：</text>{{ x.locationCode }}
					</view>
				</view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
import { navigate } from '@/utils/routerSkip.js';
import { reactive, computed, onMounted } from 'vue'
import { basPdaOperationLogFn } from '@/utils/index.js';
import { OPERATION_DEL, OPERATION_LOOK } from '@/constant/index.js'
import { useStore, } from "vuex";
import { cancelOccupy } from '@/api/api.js'
//国际化引入
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
let store = useStore()
const data = reactive({})
data.barcodeList = computed(() => {
	return store.state.transferredList
})
onMounted(() => {
	try {
		let inputParameter = '无'
		let returnParameter = JSON.stringify(data.barcodeList)
		let operationPicture = '分布式调入'
		let callInterface = '无'
		let opertionParmes = {
			inputParameter,
			returnParameter,
			operationPicture,
			callInterface,
			responseCode: '无',//返回状态
			errorMessage: '无',//错误信息
			isPass: 'Y',//是否成功 Y N
			operationType: OPERATION_LOOK,
			module: 'WMS',
			source: "PDA",
		}
		basPdaOperationLogFn(opertionParmes)
	} catch (error) {
	}
})
const deleteItem = (index, item) => {
	console.log('item', item)
	let parmes = {
		locationName:item.wmsMaterialCapacity.locationName,
		locationCode: item.locationCode,
		materialCode: item.materialCode,
		id: item.wmsMaterialCapacity.id,
		barcode: item.barcode
	}
	// 扫码取消的时候调用接口取消占用的库位
	cancelOccupy([parmes]).then(res => {
		try {
			let inputParameter = JSON.stringify(parmes)
			let returnParameter = JSON.stringify(res)
			let operationPicture = '分布式调入'
			let callInterface = res.rquestUrl
			let opertionParmes = {
				inputParameter,
				returnParameter,
				operationPicture,
				callInterface,
				responseCode: res.code,//返回状态
				errorMessage: res.msg,//错误信息
				isPass: res.code == 0 ? 'Y' : 'N',//是否成功 Y N
				operationType: OPERATION_SCAN,
				module: 'WMS',
				source: "PDA",
			}
			basPdaOperationLogFn(opertionParmes)
		} catch (error) {
		}
		if (res.code == 0) {
			uni.showToast({ title: t('fixedAssets.description'), icon: 'none', })

			store.commit('deleteTransferredList', index)
		} else {
			uni.showToast({ title: res.msg, icon: 'none', })
		}
	})
}
</script>

<style></style>
